<?php
/*
 * Created on 8 Sep 2007
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 
function replace_entities($inStr){
    $outStr = '';
     
    $outStr = str_replace('<','&lt;',$inStr);
    
    $outStr = str_replace('>','&gt;',$outStr);
    $outStr = str_replace('&','&amp;',$outStr);
    $outStr = str_replace('\'','&apos;',$outStr);
    $outStr = str_replace('"','&quot;',$outStr);
    return $outStr;
    
}

function responseToXML($response){
	$str = "";
	foreach($response as $key => $value) {
		if(is_array($value)){
			$str .="<$key>";
			foreach($value as $okey => $ovalue) {
				$str .= "<node>";
				foreach($ovalue as $subkey => $subvalue){
			   		$str .= "<$subkey>".replace_entities($subvalue)."</$subkey>";
				}
				$str .= "</node>";
			}
			$str .="</$key>";
			
		} else{
	   		$str .= "<$key>".replace_entities($value)."</$key>";
		}
	}
	return $str;
}

function formatDate($date){
	return date('d-M-Y',$date);
}
?>
